<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ include file="header.jsp" %>
<%
String orderList = (String)request.getAttribute("orderList");
String userlist = (String)request.getAttribute("userlist");


%>

			<div data-options="region:'center',border:false,title:'Callback',iconCls:'icon-popup',fit:true">
				<div id="tb_ord">
					<div style="">
					
						<form action="/conSearch.do" name="ordFm" id="ordFm" method="post">
							<a href="/toExcel.do" class="easyui-linkbutton" >엑셀로출력</a>
					        <a href="javascript:;" class="easyui-linkbutton"  onclick="Fn(2)">삭제</a>
						    주문날자<input class="easyui-datebox" name="OrdDate_s" data-options="formatter:myformatter,parser:myparser"/>~
						    <input class="easyui-datebox" name="OrdDate_e" data-options="formatter:myformatter,parser:myparser"/>
							확인<select class="easyui-combobox" name="ConfirmOrd" style="width:200px;">
								<option value="allConf">전체</option>
								<option value="1">확인</option>
								<option value="2">미확인</option>
							</select>
							<a  class="easyui-linkbutton" onclick="$('#EmpName').combobox('reload', <%=userlist%>)">사원명</a>
							<input class="easyui-combobox" id="EmpName" name="EmpName" style="width:200px;" data-options="valueField:'EmpName',textField:'text'">
						     
						    채널<select class="easyui-combobox" name="ChannelNum" style="width:200px;">
								<option value="allCh">전체</option>
								<option value="1">1채널</option>
						    	<option value="2">2채널</option>
						    	<option value="3">3채널</option>
						    	<option value="4">4채널</option>
						    </select>
						    <input type="text" name="CustName" >
						    <input type="text" name="CustPhone" >
						    <input type="submit"  value="Submit">
					  </form>  
				    </div>
				</div>
				<table id="tt"  class="easyui-datagrid" data-options="fit:true,toolbar:'#tb_ord',singleSelect:true,rownumbers:true,fitColumns:true,data:orderList,pagination:true">
			        <thead>
			            <tr>
			            	<!-- <th data-options="field:'ck',checkbox:true"></th> -->
			                <th field="ConfirmOrd" width="10%"><b>확인여부</b></th>
			                <!-- <th field="OrdDate_YYYYMMDD" width="10%"><b>주문날자</b></th>
			                <th field="OrdDate_HHMMSS" width="10%"><b>주문시간</b></th> -->
			                <th field="OrdIdx" width="10%"><b>OrdIdx</b></th>
			                <th field="OrdDate" width="10%"><b>주문날자</b></th>
			                <th field="CallerID" width="10%"><b>CallerID</b></th>
			                <th field="CustName" width="10%"><b>업체명</b></th>
			                <th field="ChannelNum" width="10"><b>채널</b></th>
			                <th field="ConfirmDate" width="10%"><b>확인날자</b></th>
			                <th field="EmpName" width="10%"><b>담당자명</b></th>
			                <th field="OrdFilename" width="10%"><b>파일명</b></th>
			           </tr>
			        </thead>
			     </table>
				
			</div>		
			<%@ include file="footer.jsp" %>
<script type="text/javascript">

$(".nav li a.menu_07").addClass('active');

var orderList = <%=orderList%>;
var userlist = <%=userlist%>;

// 칼렌더 날자 포맷 변경 YYYY-MM-DD
function myformatter(date){
    var y = date.getFullYear();
    var m = date.getMonth()+1;
    var d = date.getDate();
    return y+'-'+(m<10?('0'+m):m)+'-'+(d<10?('0'+d):d);
}
function myparser(s){
    if (!s) return new Date();
    var ss = (s.split('-'));
    var y = parseInt(ss[0],10);
    var m = parseInt(ss[1],10);
    var d = parseInt(ss[2],10);
    if (!isNaN(y) && !isNaN(m) && !isNaN(d)){
        return new Date(y,m-1,d);
    } else {
        return new Date();
    }
}

//로우 더블클릭시 청취
$('#tt').datagrid({
	onDblClickRow:function(){
		var row = $('#tt').datagrid('getSelected');
	    if (row){
	        window.open("http://localhost:8080/wav/"+row.OrdFilename);
	        
	   }
	}
	
}); 


//선택된 로우 삭제 @param : ordidx
function Fn(val){
	if(val==2){
		var ordIdx = $('#tt').datagrid('getSelected').OrdIdx;
		$.messager.confirm('OrdIdx : '+ordIdx, '삭제 하시겠습니까?', function(){
			 $('#tt').datagrid({
				url: '/ordDelete.do',
		        method:'post'
		        /*,contentType: 'application/json; charset=utf-8',
		        dataType: 'json',
		        data:$('#tt').serialize(),
		        columns:[[
					{field:'OrdIdx',title:'OrdIdx',width:100}
					 ,{field:'ConfirmOrd',title:'확인여부',width:100}
					,{field:'OrdDate',title:'주문날자',width:100}
					,{field:'CallerID',title:'CallerID',width:100}
					,{field:'CustName',title:'업체명',width:100}
					,{field:'ChannelNum',title:'채널',width:100}
					,{field:'ConfirmDate',title:'확인날자',width:100}
					,{field:'EmpName',title:'담당자명',width:100}
					,{field:'OrdFilename',title:'파일명',width:100} 
		          ]]*/
		        
				
			}); 
			//$('#deleteGrid').submit();
		});
	}
}


</script>
